package cn.jasonone.jasonfx.interceptor;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;

import cn.jasonone.jasonfx.entity.JFXBaseController;
import javafx.scene.Node;
import lombok.AllArgsConstructor;
import lombok.Data;
import net.sf.cglib.proxy.MethodProxy;

/**
 * 属性拦截器
 * 
 * @author Jason
 * @date: 2020-01-25 14:44
 * @param <T>
 */
@Data
@AllArgsConstructor
public abstract class PropertyInterceptor<T extends Node> implements ControllerInterceptor {
	private T node;
	private Object source;
	private Field field;

	@Override
	public boolean isInterceptor(Object obj, MethodProxy proxy) throws Throwable {
		PropertyDescriptor pd = new PropertyDescriptor(field.getName(), source.getClass());
		return pd.getWriteMethod().getName().equals(proxy.getSignature().getName());
	}

}
